var express = require('express');
 
var router = express.Router();
var app = express();
//npm install request --save
var request = require('request');

//当form的multipart=form-data
router.get('/demo', function (req, res) {
   request.post(
        {
            url:'http://localhost:3000/users/formdata',
            form:{
                first_name:'hahaha',
                last_name:'wowowowow'
            },
            encoding:'utf8'
        },
        function(error, response, body){
            if(response.statusCode == 200){
                // console.log(body);
                //{"first_name":"hahaha","last_name":"wowowowow"}
                res.end(body);
            }else{
                console.log(response.statusCode);
            }
        }
    );
});
 
module.exports = router;
